package com.uidp.search;

import static com.uidp.hibernatelayer.ModulDAO.MODULNAME;
import static org.apache.commons.lang.StringUtils.isNotEmpty;
import static org.hibernate.criterion.Restrictions.eq;

import com.acsior.sbc.exception.BusinessException;
import com.acsior.sbc.exception.SearchException;
import com.acsior.sbc.impl.hibernate.SearchHibernateBusinessObject;
import com.uidp.domain.Modul;
import com.uidp.hibernatelayer.ModulDAO;
import com.uidp.hibernatelayer.ModulVO;

public class ModulSearch extends
SearchHibernateBusinessObject<ModulVO, ModulDAO, Modul>  {
	
	private Modul modulCriteria;

	public ModulSearch() throws BusinessException {
		super();
	}
	
	public ModulSearch(String modulname) throws BusinessException {
		this.modulCriteria.setModulname(modulname);
	}
	
	

	/** @see SearchHibernateBusinessObject#buildCriteria() */
	@Override
	protected void buildCriteria() throws SearchException {
		super.buildCriteria();
		if (isNotEmpty(getModulCriteria().getModulname())) {
			getCriteria().add(eq(MODULNAME, getModulCriteria().getModulname()));
		}
	}

	

	/** @see SearchObject#initialize() */
	@Override
	protected final void initialize() throws BusinessException {
		super.initialize();

		this.modulCriteria = new Modul();
	}

	@Override
	protected Modul createResultObject(ModulVO d) throws BusinessException {
		return new Modul(d);
	}

	@Override
	protected Class<ModulDAO> getDAOClass() {
		return ModulDAO.class;
	}

	public Modul getModulCriteria() {
		return modulCriteria;
	}

	public void setModulCriteria(Modul modulCriteria) {
		this.modulCriteria = modulCriteria;
	}

	
}
